package com.example.springbootpro.util;

import com.example.springbootpro.empty.SysUser;

public class UserContext {
    private static final ThreadLocal<String> userHolder = new ThreadLocal<>();

    /**
     * 设置当前用户
     */
    public static void setCurrentUser(String username) {
        userHolder.set(username);
    }

    /**
     * 获取当前用户
     */
    public static String getCurrentUser() {
        return userHolder.get();
    }

    /**
     * 清除当前用户
     */
    public static void clear() {
        userHolder.remove();
    }
}